package com.zh.vis;

import cn.hutool.http.body.RequestBody;
import com.zh.vis.constants.VisConstants;
import okhttp3.*;

import java.io.IOException;

/**
 * @author :fjw
 * @description:TODO
 * @date :2020/10/8 14:52
 */
public class VisDemo {
	public static void main(String[] args) throws IOException {


	}

	/**
	 * 创建视频流
	 * @return
	 * @throws IOException
	 */
	public String create() throws IOException {
		String createUrl= VisConstants.VIS_ENDPOINT+"/v1/"+VisConstants.PROJECT_ID+"/streams";

		OkHttpClient.Builder builder = new OkHttpClient.Builder();
		OkHttpClient okHttpClient = builder.build();
		Request request = new Request.Builder().url(createUrl).get()
		.build();
		//RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), "body");

		Response response = okHttpClient.newCall(request).execute();
		if (response.isSuccessful()) {
			return response.body().toString();
		} else {
			throw new IOException("Unexpected code " + response);
		}
	}


	
}
